﻿
(function () {
    appModule.controller('common.views.versionApps.createOrEditModal', [
         '$scope', '$uibModalInstance', 'abp.services.app.versionApp', 'versionAppId',
        function ($scope, $uibModalInstance, versionAppService, versionAppId) {
            var vm = this;
            vm.saving = false;
            //首先将versionApp数据设置为null
            vm.versionApp = null;



            //触发保存方法
            vm.save = function () {
                vm.saving = true;
                versionAppService.createOrUpdateVersionAppAsync({ versionAppEditDto: vm.versionApp }).then(function () {
                    abp.notify.info(app.localize('SavedSuccessfully'));
                    $uibModalInstance.close();
                }).finally(function () {
                    vm.saving = false;
                });


            };
            //取消关闭页面
            vm.cancel = function () {
                $uibModalInstance.dismiss();
            };

            //初始化页面
            function init() {

                //绑定App标记
                versionAppService.getAllVersionFlagList().then(function (result) {
                    vm.appFlagList = result.data;
                });

                versionAppService.getVersionAppForEditAsync({
                    id: versionAppId
                }).then(function (result) {
                    vm.versionApp = result.data.versionApp;
                });
            }
            //执行初始化方法
            init();
        }
    ]);
})();